<template>
    <scroll-view
      refresher-enabled
      @refresherrefresh="onRefresherrefresh"
      :refresher-triggered="isTriggered"
      class="scroll-view"
      scroll-y
    >
    <view class="num">
        {{count}}
    </view>
    <button @click="addCount">增加1</button>
    <button @click="subCount">减少</button>
    <aa></aa>
</scroll-view>
</template>

<script setup>
  import {storeToRefs} from 'pinia'
  import {useCounterStore} from '@/stores/counter.js' 
	import aa from '../../components/cc.vue'

  import { ref } from 'vue'
  const counterStore = useCounterStore()
  const { count } = storeToRefs(counterStore)
  const isTriggered = ref(false)
  const addCount = () => {
    counterStore.increment()
  }
  const subCount = () => {
    counterStore.decrement()
  }
  const onRefresherrefresh=()=>{
    isTriggered.value=true
    setTimeout(()=>{
      addCount()
      isTriggered.value=false
    },100)
  }
</script>

<style>
.num{
    font-size: 50px;
    text-align: center;
    margin-top: 100px;
    color: royalblue;
    margin-bottom: 30rpx;
}
</style>
